#ifndef V2_NIM_CHATROOM_SERVICE_H
#define V2_NIM_CHATROOM_SERVICE_H
#include "v2_nim_internal.hpp"
namespace v2 {
/// @brief 聊天室服务
/// @pre
/// 调用 `V2NIMChatroomClient::getInstance(instanceId)` 拿到 chatroomClient 实例
/// 调用 `chatroomClient.getChatroomService()` 拿到 chatroomService 实例
/// @par 示例代码
/// @code
/// uint32_t instanceId{0};
/// // get instanceId from cache
/// // ...
/// auto& chatroomClient = V2NIMChatroomClient::getInstance(instanceId);
/// auto& chatroomService = chatroomClient.getChatroomService();
/// @endcode
class V2NIMChatroomService {
public:
    /// @brief 发送消息
    /// @param message 需要发送的消息体
    /// @param params 发送消息相关配置参数
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @param progress 附件上传进度回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// auto message = V2NIMChatroomMessageCreator::createTextMessage("hello world");
    /// auto params = V2NIMSendChatroomMessageParams();
    /// chatroomService.sendMessage(
    ///     message,
    ///     params,
    ///     [](V2NIMSendChatroomMessageResult result) {
    ///         // send message succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // send message failed, handle error
    ///     },
    ///     [](uint32_t progress) {
    ///         // upload progress
    ///     });
    /// @endcode
    virtual void sendMessage(V2NIMChatroomMessage message,
        V2NIMSendChatroomMessageParams params,
        V2NIMSuccessCallback<V2NIMSendChatroomMessageResult> success,
        V2NIMFailureCallback failure,
        V2NIMProgressCallback progress) = 0;

    /// @brief 取消文件消息附件上传
    /// @param message 要取消上传的文件消息
    /// @param success 成功回调, 返回取消上传的文件消息
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomMessage message;
    /// // ...
    /// chatroomService.cancelMessageAttachmentUpload(
    ///     message,
    ///     []() {
    ///         // cancel message attachment upload succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // cancel message attachment upload failed, handle error
    ///     });
    /// @endcode
    virtual void cancelMessageAttachmentUpload(V2NIMChatroomMessage message, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;

    /// @brief 分页获取聊天室成员列表
    /// @param queryOption 查询选项
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomMemberQueryOption queryOption;
    /// queryOption.pageToken = 0; // first page
    /// queryOption.limit = 10;
    /// chatroomService.getMemberListByOption(
    ///     queryOption,
    ///     [](V2NIMChatroomMemberListResult result) {
    ///         // get member list succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get member list failed, handle error
    ///     });
    /// @endcode
    virtual void getMemberListByOption(V2NIMChatroomMemberQueryOption queryOption,
        V2NIMSuccessCallback<V2NIMChatroomMemberListResult> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 查询历史消息
    /// @param option 查询选项
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomMessageListOption option;
    /// option.beginTime = 0;
    /// option.limit = 10;
    /// chatroomService.getMessageList(
    ///     option,
    ///     [](nstd::vector<V2NIMChatroomMessage> messages) {
    ///         // get message list succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get message list failed, handle error
    ///     });
    /// @endcode
    virtual void getMessageList(V2NIMChatroomMessageListOption option,
        V2NIMSuccessCallback<nstd::vector<V2NIMChatroomMessage>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 更新聊天室成员角色
    /// @param accountId 聊天室成员 id
    /// @param upadateParams 更新参数
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomMemberRoleUpdateParams updateParams;
    /// updateParams.memberRole = V2NIM_CHATROOM_MEMBER_ROLE_MANAGER;
    /// chatroomService.updateMemberRole(
    ///     "accountId",
    ///     updateParams,
    ///     []() {
    ///         // update member role succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // update member role failed, handle error
    ///     });
    /// @endcode
    virtual void updateMemberRole(nstd::string accountId,
        V2NIMChatroomMemberRoleUpdateParams upadateParams,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 设置聊天室成员黑名单状态
    /// @param accountId 聊天室成员 id
    /// @param blocked 黑名单状态
    /// @param notificationExtension 通知扩展字段
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// chatroomService.setMemberBlockedStatus(
    ///     "accountId",
    ///     true,
    ///     "notificationExtension",
    ///     []() {
    ///         // set member blocked status succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // set member blocked status failed, handle error
    ///     });
    /// @endcode
    virtual void setMemberBlockedStatus(nstd::string accountId,
        bool blocked,
        nstd::string notificationExtension,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 设置聊天室成员禁言状态
    /// @param accountId 聊天室成员 id
    /// @param chatBanned 禁言状态
    /// @param notificationExtension 通知扩展字段
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// chatroomService.setMemberChatBannedStatus(
    ///     "accountId",
    ///     true,
    ///     "notificationExtension",
    ///     []() {
    ///         // set member chat banned status succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // set member chat banned status failed, handle error
    ///     });
    /// @endcode
    virtual void setMemberChatBannedStatus(nstd::string accountId,
        bool chatBanned,
        nstd::string notificationExtension,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 设置聊天室成员临时禁言状态
    /// @param accountId 聊天室成员 id
    /// @param tempChatBannedDuration 临时禁言时长, 单位秒, 0 表示取消临时禁言
    /// @param notificationEnabled 是否发送通知
    /// @param notificationExtension 通知扩展字段
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// chatroomService.setMemberTempChatBanned(
    ///     "accountId",
    ///     60,
    ///     true,
    ///     "notificationExtension",
    ///     []() {
    ///         // set member temp chat banned succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // set member temp chat banned failed, handle error
    ///     });
    /// @endcode
    virtual void setMemberTempChatBanned(nstd::string accountId,
        uint64_t tempChatBannedDuration,
        bool notificationEnabled,
        nstd::string notificationExtension,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 更新聊天室信息
    /// @param updateParams 更新参数
    /// @param antispamConfig 反垃圾配置
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomUpdateParams updateParams;
    /// updateParams.roomName = "roomName";
    /// V2NIMAntispamConfig antispamConfig;
    /// chatroomService.updateChatroomInfo(
    ///     updateParams,
    ///     antispamConfig,
    ///     []() {
    ///         // update chatroom info succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // update chatroom info failed, handle error
    ///     });
    /// @endcode
    virtual void updateChatroomInfo(V2NIMChatroomUpdateParams updateParams,
        V2NIMAntispamConfig antispamConfig,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 更新自己在聊天室的成员信息
    /// @param updateParams 更新参数
    /// @param antispamConfig 反垃圾配置
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomSelfMemberUpdateParams updateParams;
    /// updateParams.roomNick = "roomNick";
    /// V2NIMAntispamConfig antispamConfig;
    /// chatroomService.updateSelfMemberInfo(
    ///     updateParams,
    ///     antispamConfig,
    ///     []() {
    ///         // update self member info succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // update self member info failed, handle error
    ///     });
    /// @endcode
    virtual void updateSelfMemberInfo(V2NIMChatroomSelfMemberUpdateParams updateParams,
        V2NIMAntispamConfig antispamConfig,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 根据账号列表查询成员信息
    /// @param accountIds 账号列表
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// chatroomService.getMemberByIds(
    ///     {"accountId1", "accountId2"},
    ///     [](nstd::vector<V2NIMChatroomMember> members) {
    ///         // get members by account ids succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get members by account ids failed, handle error
    ///     });
    /// @endcode
    virtual void getMemberByIds(nstd::vector<nstd::string> accountIds,
        V2NIMSuccessCallback<nstd::vector<V2NIMChatroomMember>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 踢出聊天室成员
    /// @param accountId 聊天室成员 id
    /// @param notificationExtension 通知扩展字段
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// chatroomService.kickMember(
    ///     "accountId",
    ///     "notificationExtension",
    ///     []() {
    ///         // kick member succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // kick member failed, handle error
    ///     });
    /// @endcode
    virtual void kickMember(nstd::string accountId,
        nstd::string notificationExtension,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 按聊天室标签临时禁言
    /// @param params 设置标签禁言的参数
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomTagTempChatBannedParams params;
    /// params.tags = "tag1";
    /// params.duration = 60;
    /// params.notificationEnabled = true;
    /// params.notificationExtension = "notificationExtension";
    /// chatroomService.setTempChatBannedByTag(
    ///     params,
    ///     []() {
    ///         // set temp chat banned by tag succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // set temp chat banned by tag failed, handle error
    ///     });
    /// @endcode
    virtual void setTempChatBannedByTag(V2NIMChatroomTagTempChatBannedParams params,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 根据标签查询成员列表
    /// @param option 查询成员列表的参数
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomTagMemberOption option;
    /// option.tag = "tag1";
    /// option.pageToken = "";
    /// option.limit = 10;
    /// chatroomService.getMemberListByTag(
    ///     option,
    ///     [](V2NIMChatroomMemberListResult result) {
    ///         // get member list by tag succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get member list by tag failed, handle error
    ///     });
    /// @endcode
    virtual void getMemberListByTag(V2NIMChatroomTagMemberOption option,
        V2NIMSuccessCallback<V2NIMChatroomMemberListResult> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 查询某个标签下的成员人数
    /// @param tag 标签
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// chatroomService.getMemberCountByTag(
    ///     "tag1",
    ///     [](uint64_t count) {
    ///         // get member count by tag succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get member count by tag failed, handle error
    ///     });
    /// @endcode
    virtual void getMemberCountByTag(nstd::string tag, V2NIMSuccessCallback<uint64_t> success, V2NIMFailureCallback failure) = 0;

    /// @brief 更新坐标信息
    /// @param locationConfig 坐标信息
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomLocationConfig locationConfig;
    /// locationConfig.locationInfo.x = 1.0;
    /// locationConfig.locationInfo.y = 1.0;
    /// locationConfig.locationInfo.z = 1.0;
    /// locationConfig.distance = 100;
    /// chatroomService.updateChatroomLocationInfo(
    ///     locationConfig,
    ///     []() {
    ///         // update chatroom location info succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // update chatroom location info failed, handle error
    ///     });
    /// @endcode
    virtual void updateChatroomLocationInfo(V2NIMChatroomLocationConfig locationConfig,
        V2NIMSuccessCallback<void> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 更新聊天室 tag 信息
    /// @param updateParams tag 更新的参数
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomTagsUpdateParams updateParams;
    /// updateParams.tags = {"tag1", "tag2"};
    /// updateParams.notifyTargetTags = R"({"tag": "tag1"})";
    /// chatroomService.updateChatroomTags(
    ///     updateParams,
    ///     []() {
    ///         // update chatroom tags succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // update chatroom tags failed, handle error
    ///     });
    /// @endcode
    virtual void updateChatroomTags(V2NIMChatroomTagsUpdateParams updateParams, V2NIMSuccessCallback<void> success, V2NIMFailureCallback failure) = 0;

    /// @brief 根据标签查询消息列表
    /// @param messageOption 查询参数
    /// @param success 成功回调
    /// @param failure 失败回调
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomTagMessageOption messageOption;
    /// messageOption.tags = {"tag1", "tag2"};
    /// messageOption.limit = 10;
    /// chatroomService.getMessageListByTag(
    ///     messageOption,
    ///     [](nstd::vector<V2NIMChatroomMessage> messages) {
    ///         // get message list by tag succeeded
    ///     },
    ///     [](V2NIMError error) {
    ///         // get message list by tag failed, handle error
    ///     });
    /// @endcode
    virtual void getMessageListByTag(V2NIMChatroomTagMessageOption messageOption,
        V2NIMSuccessCallback<nstd::vector<V2NIMChatroomMessage>> success,
        V2NIMFailureCallback failure) = 0;

    /// @brief 添加聊天室监听器
    /// @param listener 聊天室监听器
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomListener listener;
    /// listener.onReceiveMessages = [](nstd::vector<V2NIMChatroomMessage> messages) {
    ///     // handle receive messages
    /// };
    /// listener.onChatroomMemberEnter = [](V2NIMChatroomMember member) {
    ///     // handle chatroom member enter
    /// };
    /// listener.onChatroomMemberExit = [](nstd::string accountId) {
    ///     // handle chatroom member exit
    /// };
    /// listener.onChatroomMemberRoleUpdated = [](V2NIMChatroomMemberRole previousRole, V2NIMChatroomMember member) {
    ///     // handle chatroom member role updated
    /// };
    /// listener.onChatroomMemberInfoUpdated = [](V2NIMChatroomMember member) {
    ///     // handle chatroom member info updated
    /// };
    /// listener.onSelfChatBannedUpdated = [](bool chatBanned) {
    ///     // handle self chat banned updated
    /// };
    /// listener.onSelfTempChatBannedUpdated = [](bool tempChatBanned, uint64_t tempChatBannedDuration) {
    ///     // handle self temp chat banned updated
    /// };
    /// listener.onChatroomInfoUpdated = [](V2NIMChatroomInfo chatroomInfo) {
    ///     // handle chatroom info updated
    /// };
    /// listener.onChatroomChatBannedUpdated = [](bool chatBanned) {
    ///     // handle chatroom chat banned updated
    /// };
    /// listener.onMessageRevokedNotification = [](nstd::string messageClientId, uint64_t messageTime) {
    ///     // handle message revoked notification
    /// };
    /// listener.onChatroomTagsUpdated = [](nstd::vector<nstd::string> tags) {
    ///     // handle chatroom tags updated
    /// };
    /// chatroomService.addChatroomListener(listener);
    /// @endcode
    virtual void addChatroomListener(V2NIMChatroomListener listener) = 0;

    /// @brief 移除聊天室监听器
    /// @param listener 聊天室监听器
    /// @return void
    /// @par 示例代码
    /// @code
    /// V2NIMChatroomListener listener;
    /// // ...
    /// chatroomService.addChatroomListener(listener);
    /// // ...
    /// chatroomService.removeChatroomListener(listener);
    /// @endcode
    virtual void removeChatroomListener(V2NIMChatroomListener listener) = 0;
};
}  // namespace v2
#endif
